//
//  HHMessagesViewController.h
//  HHChatKit
//
//  Created by Henry on 2021/5/8.
//

#import <UIKit/UIKit.h>
#import <HHKeyboard/HHKeyboardView.h>
#import "HHNoticeView.h"
#import "HHTextMessageCell.h"
#import "HHSystemMessageCell.h"
#import "HHImageMessageCell.h"
#import "HHVoiceMessageCell.h"
#import "HHVideoMessageCell.h"
#import "HHFaceMessageCell.h"
#import "HHFileMessageCell.h"

@class HHMessagesViewController;

NS_ASSUME_NONNULL_BEGIN

@protocol HHMessagesViewControllerDelegate <NSObject>

@optional

/// 配置长按弹出的UIMenu菜单
- (NSArray <NSString *> *)messageController:(HHMessagesViewController *)controller menuItemIncell:(HHMessageCell *)cell;

/// 点击UIMenu菜单
- (void)messageController:(HHMessagesViewController *)controller onSelectMenu:(NSString *)title msg:(HHMessageCellData *)msg ;


/// 点击消息头像
- (void)messageController:(HHMessagesViewController *)controller onSelectMessageAvatar:(HHMessageCell *)cell;

/// 点击消息内容
- (void)messageController:(HHMessagesViewController *)controller onSelectMessageContent:(HHMessageCell *)cell;

/// 点击keybooard更多
- (void)messageController:(HHMessagesViewController *)controller onSelectMoreItem:(HHKeyboardMoreItem *)item;

/// 点击HHNoticeView Title
- (void)messageController:(HHMessagesViewController *)controller noticeView:(HHNoticeView *)noticeView clickTitle:(NSString *)title;

@end

@interface HHMessagesViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, weak) id<HHMessagesViewControllerDelegate> delegate;

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) HHKeyboardView *keyboardView;
@property (nonatomic, strong) HHNoticeView *noticeView;


@property (nonatomic, strong) NSMutableArray *dataArray;

@property (nonatomic, copy) NSString *conversationId;


/// 消息时间间隔（300秒）
@property (nonatomic, assign) NSInteger messageTimeInterval;

/// 发送者
@property (nonatomic, copy) NSString *senderId;
@property (nonatomic, copy) NSString *senderName;



- (void)loadMessage:(HHMessageCellData *)msg complation:(void(^)(BOOL status, NSArray *msgs))complation;

- (void)sendMessage:(HHMessageCellData *)msg complation:(void(^)(BOOL status, HHMessageCellData *msg))complation;
                                                         
- (void)setMoreItem:(NSMutableArray <HHKeyboardMoreItem *> *)items;


/// 配置布局，size改变时
- (void)configLayout:(CGSize)size;
/// 收起键盘
- (void)hiddenKeyboard;
/// 是否展示时间提示
- (BOOL)showTimeFrom:(NSString *)time;
- (void)showMessageTimeWithData:(HHMessageCellData *)data;
/// 改变消息状态
- (void)changeMsg:(HHMessageCellData *)msg status:(HHMsgStatus)status;
/// 滚动到底部
- (void)scrollToBottom:(BOOL)animate;
/// 更新TableView TopInset
- (void)updateTableViewTopInset:(CGFloat)top;
/// 更新TableView BottomInset
- (void)updateTableViewBottomInset:(CGFloat)bottom;

/// 接受消息
- (void)acceptMessages:(NSArray<HHMessageCellData *> *)msgs;
/// 发送消息
- (void)sendMessage:(HHMessageCellData *)msg;
- (void)sendMessageText:(NSString *)text;
- (void)sendMessageImage:(UIImage *)image;
- (void)sendMessageVoice:(NSDictionary *)voice;
- (void)sendMessageSystem:(NSString *)system;

- (void)onDelete;

/// 撤回消息
/// @param text 显示的内容
/// @param msgId 消息ID
- (void)onRevoke:(NSString *)text msgId:(NSString *)msgId;
/// 没有消息ID，取值menuMsg，可用于点击UIMenu时。点击后menuMsg=nil
- (void)onRevoke:(nullable NSString *)text;

- (NSIndexPath *)indexPathOfMsg:(HHMessageCellData *)msg;
- (NSIndexPath *)indexPathOfMsgId:(NSString *)msgId;
- (HHMessageCellData *)dataOfUUID:(NSString *)uuid;

- (void)showImageMessage:(HHImageMessageCell *)cell;

@end

NS_ASSUME_NONNULL_END
